package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SeatCall;
import com.ruoyi.system.service.ISeatcallService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对讲记录Controller
 * 
 * @author ruoyi
 * @date 2025-04-17
 */
@Controller
@RequestMapping("/system/seatcall")
public class SeatCallController extends BaseController
{
    private String prefix = "system/seatcall";

    @Autowired
    private ISeatcallService seatcallService;

    @RequiresPermissions("system:seatcall:view")
    @GetMapping()
    public String seatcall()
    {
        return prefix + "/seatcall";
    }

    /**
     * 查询对讲记录列表
     */
    @RequiresPermissions("system:seatcall:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SeatCall seatcall)
    {
        startPage();
        List<SeatCall> list = seatcallService.selectSeatcallList(seatcall);
        return getDataTable(list);
    }

    /**
     * 导出对讲记录列表
     */
    @RequiresPermissions("system:seatcall:export")
    @Log(title = "对讲记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SeatCall seatcall)
    {
        List<SeatCall> list = seatcallService.selectSeatcallList(seatcall);
        ExcelUtil<SeatCall> util = new ExcelUtil<SeatCall>(SeatCall.class);
        return util.exportExcel(list, "对讲记录数据");
    }

    /**
     * 新增对讲记录
     */
    @RequiresPermissions("system:seatcall:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存对讲记录
     */
    @RequiresPermissions("system:seatcall:add")
    @Log(title = "对讲记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SeatCall seatcall)
    {
        return toAjax(seatcallService.insertSeatcall(seatcall));
    }

    /**
     * 修改对讲记录
     */
    @RequiresPermissions("system:seatcall:edit")
    @GetMapping("/edit/{gbLaneId}")
    public String edit(@PathVariable("gbLaneId") String gbLaneId, ModelMap mmap)
    {
        SeatCall seatcall = seatcallService.selectSeatcallByGbLaneId(gbLaneId);
        mmap.put("seatcall", seatcall);
        return prefix + "/edit";
    }

    /**
     * 修改保存对讲记录
     */
    @RequiresPermissions("system:seatcall:edit")
    @Log(title = "对讲记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SeatCall seatcall)
    {
        return toAjax(seatcallService.updateSeatcall(seatcall));
    }

    /**
     * 删除对讲记录
     */
    @RequiresPermissions("system:seatcall:remove")
    @Log(title = "对讲记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(seatcallService.deleteSeatcallByGbLaneIds(ids));
    }
}
